<?php


namespace Lib\Component;


use Config\Db;

class Redis extends \Redis implements ComponentInterface
{
    private static $instance = null;

    private function __construct()
    {
    }

    /**
     * 获取单例对象
     * @return Redis|null
     */
    public static function getInstance() {
        if (self::$instance == null) {
            self::$instance = new static();
            self::$instance->register();
        }
        return self::$instance;
    }

    /**
     * 理解redis
     */
    public function register()
    {
        self::$instance->connect(Db::REDIS_HOST, 6379);
    }
}